@extends('layouts.master3')
@section("title")
{{$dis->title}}
@endsection
@section("edstyle")
    <link rel="stylesheet" href="/css/edit/style.css">
    <link rel="stylesheet" href="/css/atelier-heath-light.css">
@endsection
@section("css")
    <link href="/css/discuss.css" rel="stylesheet">
@endsection
@section("content")
<?php
use App\Utils;
use App\Permission;
?>
<div class="contain">

    <div class="qa-body-wrapper">
        <div class="qa-main-shadow">
            <div class="qa-main-wrapper">

                <!-- nav-main E-->
                <div class="qa-sidepanel">
                    <div class="" style="margin-bottom:20px;">
@if(count($tasks)>0)
                        <a target="_blank" href="/task/{{Utils::id2url($tasks[0]->id)}}"class="btn btn-primary back-q">查看task</a>
@endif
                    </div>
                    <div class="qa-sidebar well">
                        @include('dis.bulletin')
                    </div>
                    
                </div>
                <!-- qa-sidebar E-->
                <div class="qa-main qa-template-question">
                    <div class="qa-part-q-view">
                        <div class="qa-q-view  hentry question" id="q15521">
                            <div class="qa-q-view-stats">
                                <div class="qa-voting qa-voting-net" id="">
                                    <a target="_blank" href="/profile/{{Utils::id2url($dis->userid)}}"><img src="{{$dis->user->avatar->url('thumb')}}" alt="用户头像avatar"></a>
                                </div>
                            </div>
                            <div class="qa-q-view-main">
                                <span class="qa-view-count">
                                </span>
                                <div class="qa-q-view-content">
                                    <a class="qa-q-title">{{$dis->title}}</a>
                                    <div class="entry-content markdown-body">
<?php echo $dis->content;?>

                                    </div>
                                </div>

                                <span class="qa-q-view-avatar-meta">
                                    <span class="qa-q-view-meta">
                                        <a target="_blank" href="/profile/{{Utils::id2url($dis->userid)}}" class="qa-user-link gray"> {{$dis->user->name}}</a>
										<span class="qa-q-view-when"> {{$dis->created_at}} 提问 @if ($dis->user->id==Auth::user()->id || Permission::user_is_super(Auth::user()) )
 <a href="/q/{{Utils::id2url($dis->id)}}/edit">编辑</a> 
@endif</span>                           <a class="qa-q-item-class gray" href="/discuss/{{$dis->tag}}" target="_blank"> {{$dis->tag}}</a>
                                    </span>
                                </span>
                            </div> <!-- END qa-q-view-main -->
                            <div class="qa-q-view-clear">
                            </div>
                        </div>

                    </div><!-- END qa-q-view -->
                    <div class="qa-part-a-list">
                        <div id="a_list_title"><a href="/q/{{Utils::id2url($dis->id)}}">查看全部 {{$dis->ansnum}} 个回答</a></div>
                        <div class="qa-a-list" id="a_list">
@foreach($comments as $com)
                            <div class="qa-a-list-item  hentry answer" id="{{Utils::id2url($com->id)}}">
                                <div class="vote pull-left">
                                    <button class="up @if($com->fav==0) press @endif" data-token="{{csrf_token()}}" data-id="{{Utils::id2url($com->id)}}" data-type="1" title="赞同">
                                        <i class="vote_arrow"></i>
                                        <span class="count" data-count="{{$com->vote}}">{{$com->vote}}</span>
                                    </button>
                                </div>
                                <div class="qa-a-item-main">

                                    <div class="qa-a-item-content">
                                        <a  class="qa-user-link fl black" target="_blank" href="/profile/{{Utils::id2url($com->userid)}}">{{$com->user->name}}，  </a><span class="fl overhidden qa-a-intr">{{$com->user->introduce}}</span>
                                        <a  class="qa-a-avatar"target="_blank" href="/profile/{{Utils::id2url($com->userid)}}"><img src="{{$com->user->avatar->url('thumb')}}" width="30" height="30" class="fr"></a>
                                        <div class="clear"></div>
										<div class="entry-content markdown-body"><p><?php echo $com->comment;?></p></div>
                                    </div>
                                    <span class="qa-a-item-avatar-meta">

                                        <span class="qa-a-item-meta">
											<span class="qa-a-item-when">{{$com->created_at}}
@if (Auth::user()->id==$com->userid|| Permission::user_is_super(Auth::user()) )
<a target="_blank" class="gray" href="/editdis/{{Utils::id2url($com->id)}}"> 编辑 </a>
<a target="_blank" class="gray" href="/deldis/{{Utils::id2url($com->id)}}"> 删除 </a>
@endif
</span>
                                            <!-- <a href="javascript:;" class="gray _pl"> {{count($com->respons)}}条评论</a> -->

                                        </span>

                                    </span>
                                    <div class="dc" >
                                        <div class="qa-comment-list">
@foreach($com->respons as $r)
                                            <div class="media" id="">
                                                <a class="pull-left" target="_blank" href="/profile/{{Utils::id2url($r->user->id)}}">
                                                    <img class="img-circle" alt="Cinque Terre" width="20" height="20" src="{{$r->user->avatar->url("thumb")}}">
                                                </a>
                                                <div class="media-body">
                                                    <input type="hidden" class="replyName" value="{{$r->user->name}}">
                                                    <h4 class="media-heading"><a  target="_blank" href="/profile/{{Utils::id2url($r->user->id)}}" class="gray">{{$r->user->name}}</a> @if($r->ruserid!=0) 回复了 <a  target="_blank" href="/profile/{{Utils::id2url($r->ruserid)}}" class="gray">{{$r->ruser->name}} </a>@endif
                                                        <!--<a target="_blank" href="/admin/del?id=3445">删除</a>-->
                                                    </h4>
{{$r->comment}}
                                                    <div class="ql_comment_ft">
                                                        <span class="date">{{$r->created_at}}</span>
                                                        <?php
                                                            if(Auth::user()->id!==$r->user->id){
                                                                echo '<a href="javascript:;" class="reply ql_comment_op_link gray" name="reply_comment">回复</a>';
                                                            }
                                                        ?>
                                                       
                                                    </div>

                                                    <div class="ql_comment_form expanded" style="display: none;">
                                                        <div class="ql_comment_editable_wrap">
                                                            <input class="ql_comment_editable editable"  placeholder="写下你的评论" type="text">
                                                        </div>
                                                        <div class="ql_command ql_clear">
                                                            <a href="javascript:;" class="btn btn-primary pull-right replyBtn" data-mid="{{Utils::id2url(Auth::user()->id)}}" data-id="{{$com->id}}" data-rid="{{Utils::id2url($r->user->id)}}" data-name="{{Auth::user()->name}}" data-token="{{csrf_token()}}" data-img="{{Auth::user()->avatar->url('thumb')}}" data-rtype="3">回复</a>
                                                            <a href="javascript:;" class="ql_comment_close ql_command_cancel">取消</a>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div><!-- media END-->
@endforeach
                                            
                                        </div>
                                        <div class="qa-a-reply">
                                            <input class="ql_comment_editable editable"  placeholder="写下你的评论" type="text">
                                            <div class="ql_command ql_clear none">
                                                <a href="javascript:;" class="btn btn-primary pull-right qa-replyBtn" data-mid="{{Utils::id2url(Auth::user()->id)}}" data-id="{{$com->id}}" data-token="{{csrf_token()}}" data-name="{{Auth::user()->name}}" data-img="{{Auth::user()->avatar->url('thumb')}}" data-rtype="3">回复</a>
                                                <a href="javascript:;" class="qa-ql_comment_close qa-ql_command_cancel">取消</a>
                                            </div>
                                        </div>
                                    </div>

                                </div> <!-- END qa-a-item-main -->
                                <div class="qa-a-item-clear"></div>


                            </div> <!-- END qa-a-list-item -->
@endforeach
                 
                        </div> <!-- END qa-a-list -->

                    </div>
<?php echo $comments->render();?>
                    <!--<div class="qa-suggest-next">-->
                        <!--<a href="">加载更多</a>-->
                    <!--</div>-->
                </div>
            </div>
        </div>
    </div>

</div>
@endsection
@section("js")
<script src="/js/jquery.min.js"></script>
<script src="/js/editormd.js?v=1.0"></script>
<script src="/js/vote.js"></script>
<script src="/js/reply.js"></script>
<script src="/js/highlight.pack.js"></script>
<script async src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"></script>
@endsection
